import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialMasterVO, MaterialMasterForm, MaterialMasterQuery } from '@/api/manu/materialMaster/types';

/**
 * 查询变更主数据列表
 * @param query
 * @returns {*}
 */

export const listMaterialMaster = (query?: MaterialMasterQuery): AxiosPromise<MaterialMasterVO[]> => {
  return request({
    url: '/manu/materialMaster/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询变更主数据详细
 * @param id
 */
export const getMaterialMaster = (id: string | number): AxiosPromise<MaterialMasterVO> => {
  return request({
    url: '/manu/materialMaster/' + id,
    method: 'get'
  });
};

/**
 * 新增变更主数据
 * @param data
 */
export const addMaterialMaster = (data: MaterialMasterForm) => {
  return request({
    url: '/manu/materialMaster',
    method: 'post',
    data: data
  });
};

/**
 * 修改变更主数据
 * @param data
 */
export const updateMaterialMaster = (data: MaterialMasterForm) => {
  return request({
    url: '/manu/materialMaster',
    method: 'put',
    data: data
  });
};

/**
 * 删除变更主数据
 * @param id
 */
export const delMaterialMaster = (id: string | number | Array<string | number>) => {
  return request({
    url: '/manu/materialMaster/' + id,
    method: 'delete'
  });
};
